class JenkinsManager:
    def __init__(self, jenkins_url, username=None, password=None):
        self.jenkins_url = jenkins_url
        self.username = username
        self.password = password

    def trigger_build(self, job_name: str, parameters: dict = None) -> int:
        """触发Jenkins构建"""
        import jenkins
        server = jenkins.Jenkins(self.jenkins_url, username=self.username, password=self.password)
        
        # 触发构建并返回构建号
        queue_id = server.build_job(job_name, parameters=parameters)
        build_number = server.get_queue_item(queue_id)['executable']['number']
        return build_number

    def get_build_status(self, job_name: str, build_number: int) -> str:
        """获取构建状态"""
        import jenkins
        server = jenkins.Jenkins(self.jenkins_url, username=self.username, password=self.password)
        build_info = server.get_build_info(job_name, build_number)
        return build_info['result'] 